[id].vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <!-- 页面头部 -->
  3. <HomePageHead></HomePageHead>
  4. <!-- 导航栏 -->
  5. <HomePageNavigation1></HomePageNavigation1>
  6. <!-- 列表页广告一 -->
  7. <HomeTopTen :imgurl="adList[0]" v-if="adList[0]"></HomeTopTen>
  8. <!-- 面包屑导航 -->
  9. <div class="breadcrumb">
  10. <div class="inner">
  11. <span class="location">当前位置:</span>
  12. <el-breadcrumb :separator-icon="ArrowRight">
  13. <el-breadcrumb-item>
  14. <NuxtLink to="/">首页</NuxtLink>
  15. </el-breadcrumb-item>
  16. <el-breadcrumb-item >
  17. <NuxtLink :to="{ path: `/newsList/${routLevelId}` }">
  18. {{ routLevelTitle }}
  19. </NuxtLink>
  20. </el-breadcrumb-item>
  21. <el-breadcrumb-item>{{ routeNewsTtitle }}</el-breadcrumb-item>
  22. </el-breadcrumb>
  23. </div>
  24. </div>
  25. <!-- 资讯列表 -->
  26. <div class="newsDetail">
  27. <div class="inner">
  28. <div class="innerLeft">
  29. <div class="LeftTop">
  30. <h1>{{ newsDetail.title }}</h1>
  31. <p>
  32. 来源: <span>{{ newsDetail.copyfrom }}</span>
  33. 作者: <span>{{ newsDetail.author }}</span>
  34. 发布时间: <span>{{ time }}</span>
  35. </p>
  36. <!-- <img :src="newsDetail.imgurl" v-if="newsDetail.imgurl&&newsDetail.level==2||newsDetail.level==3"> -->
  37. </div>
  38. <div class="leftBottom" v-html="newsDetail.content" v-if="newsDetail.content"></div>
  39. <!-- 免责声明: -->
  40. <div class="disclaimer" v-if="newsDetail.copyfrom!='本网'">
  41. <p>原文链接:{{ newsDetail.fromurl }}</p>
  42. <p>[免责声明]本文来源于网络转载,仅供学习交流使用,不构成商业目的。 版权归原作者所有,如涉及作品内容,版权和其他问题,请在30日与本网联系,我们将第一时间处理。</p>
  43. </div>
  44. </div>
  45. <div class="innerRight">
  46. <!-- 热点资讯1 -->
  47. <div class="hotList1">
  48. <DetailHotNews></DetailHotNews>
  49. </div>
  50. <!-- 热点资讯2 -->
  51. <div class="hotList2">
  52. <DetailHotNews2></DetailHotNews2>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. <!-- 页面底部 -->
  58. <HomeFoot1></HomeFoot1>
  59. </template>
  60. <script setup>
  61. //1.页面依赖 start ---------------------------------------->
  62. import { onMounted } from 'vue'
  63. import { ElBreadcrumb, ElBreadcrumbItem } from 'element-plus'
  64. import { ArrowRight } from '@element-plus/icons-vue'
  65. const nuxtApp = useNuxtApp();
  66. const axios = nuxtApp.$axios;
  67. //获得跳转过来的id
  68. const route = useRoute();
  69. const articleId = route.params.id; //获得该页面的id
  70. //1.页面依赖 end ---------------------------------------->
  71. //2.页面数据 start ---------------------------------------->
  72. //2.1 资讯详情
  73. const newsDetail = ref({})
  74. const routeNewsTtitle = ref("");
  75. //2.2 发布日期
  76. const time = ref("");
  77. //2.3 路径
  78. const routLevelTitle = ref("");
  79. const routLevelId = ref("");
  80. //2.4获取详情
  81. async function getPageData() {
  82. const mkdata = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  83. method: 'GET',
  84. query: {
  85. 'articleid': articleId
  86. },
  87. });
  88. if(mkdata.code==200){
  89. //获取内容
  90. newsDetail.value = mkdata.data;
  91. //获取路径
  92. routLevelTitle.value = newsDetail.value.cat_name;
  93. routLevelId.value = newsDetail.value.category_id;
  94. //获取发布时间
  95. time.value = newsDetail.value.updated_at.split(' ')[0];
  96. //修正标题长度
  97. if (newsDetail.value.title.length >= 30) {
  98. routeNewsTtitle.value = newsDetail.value.title.substr(0, 30) + "...";
  99. } else {
  100. routeNewsTtitle.value = newsDetail.value.title
  101. }
  102. }else{
  103. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  104. console.log("错误位置:获取详情内容")
  105. console.log("后端错误反馈:",mkdata.message)
  106. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  107. }
  108. }
  109. getPageData();
  110. //2.5 获得广告
  111. //广告列表
  112. let adList = ref([]);
  113. async function getAdData(){
  114. const adData = await requestDataPromise('/web/getWebsiteAdvertisement',{method:'GET',query:{'ad_tag':'DETAIL'}});
  115. if(adData.code==200){
  116. adList.value = adData.data;
  117. }else{
  118. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  119. console.log("错误位置:获取详情页广告列表")
  120. console.log("后端错误反馈:",adData.message)
  121. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  122. }
  123. }
  124. getAdData();
  125. //2.页面数据 end ---------------------------------------->
  126. //3.设置seo信息 start---------------------------------------->
  127. //3.1 设置seo信息
  128. const setData = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  129. method: 'GET',
  130. query: {
  131. 'articleid': articleId
  132. },
  133. });
  134. if(setData.code==200){
  135. let seoTitle = setData.data.title;
  136. let seoDescription = setData.data.introduce;
  137. let seoKeywords = setData.data.keyword;
  138. let seoSuffix = setData.data.suffix;
  139. let seoName = setData.data.website_name;
  140. useSeoMeta({
  141. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  142. meta: [
  143. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix },
  144. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix }
  145. ]
  146. });
  147. }else{
  148. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  149. console.log("错误位置:设置详情页面SEO数据")
  150. console.log("后端错误反馈:",setData.message)
  151. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  152. }
  153. //4.设置seo信息 end---------------------------------------->
  154. </script>
  155. <style lang="less" scoped>
  156. @import url('@/assets/css/detail.less');
  157. </style>